package com.offcn.sms.listener;

import com.offcn.sms.util.SmsUtil;
import org.apache.http.HttpResponse;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class SmsListener {


    @Autowired
    private SmsUtil smsUtil;

    @RabbitListener(queues = "sms_queue")
    public void getMessage(Map<String, String> map) {
        if (map != null && map.size() > 0) {
            String phone = map.get("phone");
            String code = map.get("code");
            HttpResponse response = smsUtil.sendSms(phone, code);
        }
    }


}
